layui.define(["layer", "jquery"], function(exports) {
    var $ = layui.jquery;
    var obj = {
        login : function ($data,$url) {
            $.ajax({
                type: "post",
                url: $url,
                data: data.field,
                dataType: "json",
                success: function(data){
                    if (data['status'] == 200 && data){
                        layer.msg(data.msg,{icon:1},function () {
                            window.location.href = "/";
                        });
                    }else{
                        $("#captcha").click();
                        layer.msg(data.msg,{icon:2});
                    }
                },
                error :function (xhr) {

                }
            });
        }
    }
    exports("login", obj);
});